package kr.saeildamil.androidstudy_second24;

import kr.saeildamil.androidstudy_second.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ValueAnimatorTest2 extends Activity {
	Button mbtn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch24_valueanimator);
		mbtn=(Button) findViewById(R.id.ch24_valueanimator_btn02);
		
	}
	public void mOnClick(View v){
		ValueAnimator anim=ValueAnimator.ofInt(150,400);
		anim.setDuration(2000);
		anim.setInterpolator(null);
		anim.setRepeatCount(1);
		anim.setRepeatMode(ValueAnimator.REVERSE);
		anim.addListener(new AnimatorListenerAdapter() {
			@Override
			public void onAnimationStart(Animator animation) {
				// TODO Auto-generated method stub
				super.onAnimationStart(animation);
				Toast.makeText(ValueAnimatorTest2.this, "start", 0).show();
			}
			@Override
			public void onAnimationEnd(Animator animation) {
				// TODO Auto-generated method stub
				super.onAnimationEnd(animation);
				Toast.makeText(ValueAnimatorTest2.this, "end", 0).show();
			}
		});
		
		anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
			
			@Override
			public void onAnimationUpdate(ValueAnimator animation) {
				mbtn.setWidth((Integer) animation.getAnimatedValue());
			}
			
		});
		anim.start();
	}
}
